let app = getApp()
Component({
    properties: {
        tabbarList: {
          type: Array,
        },
        now_index: {
          type:Number
        }
      },
    lifetimes: {
        // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
        attached: function () {
            var that=this
            wx.request({
              url: app.globalData.siteroot,
              data: {
                do:'Video_getVideo',
              },
              success: function(res) {
                  that.setData({
                    tabbar:res.data.info.tabbar,
                    nativeTabbar:res.data.info.tabbar.show,
                    list:res.data.info.tabbar.list,
                    titleShow:res.data.info.tabbar.show,
                    globalColor:res.data.info.common.globle.color
                  }) 
                  wx.setStorageSync('tabbar',res.data.info.tabbar);
                  if(typeof(res.data.info.tabbar.list[3])!='undefined'){
                    app.globalData.goodclassname=res.data.info.tabbar.list[3].link.type_name
                  }
                  app.globalData.globalColor=res.data.info.common.globle.color
                  that.triggerEvent ('refresh_data',res.data)
              }
            })
            
         }
      },
    methods: {
        choosenav:function(e){
            const type = e.currentTarget.dataset.type;
            const title = e.currentTarget.dataset.title;
            this.setData({
              title:e.currentTarget.dataset.title
            })
            const key = e.currentTarget.dataset.key;
            if(type=='page'){
              var that=this
              wx.request({
                url: app.globalData.siteroot,
                data: {
                  do:'index_pagedata',
                  id:e.currentTarget.dataset.pageid
                },
                success: function(res) {
                  that.setData({
                    title:res.data.info.page.name
                  })
                  var choose=[];
                  choose['pageid']= e.currentTarget.dataset.pageid;
                  choose['now_index']=key;
                  choose['tabbar_title']=res.data.info.page.name; 
                  choose['tabbar_type']=type; 
                  choose['titleShow']=that.data.titleShow;
                  choose['globalColor']=that.data.globalColor;
                  that.setData({
                      now_index:key 
                  })
                  that.triggerEvent ('get_type',choose)
                }
              })
            }else{
              var choose=[];
              choose['pageid']= e.currentTarget.dataset.pageid;
              choose['now_index']=key;
              choose['tabbar_title']=this.data.title; 
              choose['tabbar_type']=type; 
              choose['titleShow']=this.data.titleShow;
              choose['globalColor']=this.data.globalColor;
              this.setData({  
                  now_index:key 
              })
              this.triggerEvent ('get_type',choose)
            }
        }
    }
});
